<template>
	<view class="container">
		<view class="title">
			<img src="@/static/app_icon.png" alt="" style="width: 130rpx;height: 100rpx;" />
			<text class="title-text">毕设助手</text>
		</view>
		<view class="desc">
			毕设管理系统客户端
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				timer: null // 用于保存计时器ID
			}
		},
		onShow() {
			this.startTimer();
		},
		methods: {
			startTimer() {
				this.timer = setTimeout(() => {
					this.redirectToTargetPage();
				}, 2000); // 2000毫秒即2秒后跳转
			},
			redirectToTargetPage() {
				// 根据实际需求选择合适的跳转方式
				this.checkLogin()
			},
			checkLogin() {
				if (!uni.getStorageSync("user-token")) {
					uni.reLaunch({
						url: '/pages/login/login'
					})
				} else {
					uni.reLaunch({
						url: '/pages/task/task'
					})
				}
			}
		},
		onDestroyed() {
			// 页面关闭时清除定时器
			if (this.timer) {
				clearTimeout(this.timer);
			}
		}
	}
</script>

<style lang="scss">
.container {
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
		height: 100vh;
		padding: 0 20rpx;
		background-color: #ffffff;

		.title {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.icon {
				width: 80rpx;
				height: 80rpx;
			}

			.title-text {
				font-size: 40rpx;
				font-family: "Microsoft YaHei", 微软雅黑;
				color: rgb(51, 51, 51);
			}
		}

		.desc {
			margin-top: 32rpx;
			color: rgb(164, 161, 161);
		}
	}
</style>
